package cn.ctodb.im.dto;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.io.Serializable;

/**
 * All rights Reserved, Designed By www.ctodb.cn
 *
 * @version V1.0
 * @author: lichaohn@163.com
 * @date: 2018-11-12 16:52
 * @Copyright: 2018 www.ctodb.cn All rights reserved.
 */
public abstract class AbstractDTO<T> implements Serializable {

    private Status status = Status.OK;
    private int errorCode = 0;
    private String errMsg = "";

    public abstract void fromProto(T t);

    public abstract T toProto();

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
    }

    public Status getStatus() {
        return status;
    }

    public void setStatus(Status status) {
        this.status = status;
    }

    public int getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrMsg() {
        return errMsg;
    }

    public void setErrMsg(String errMsg) {
        this.errMsg = errMsg;
    }

    public enum Status {
        /**
         * 成功
         */
        OK,
        /**
         * 请求失败
         */
        ERROR,
        /**
         * 处理失败
         */
        ACT_ERROR,
        /**
         * 业务失败
         */
        BUSS_ERROR;
    }
}
